﻿using Kanban.Dapper.Dal;
using Kanban.IDal;
using Kanban.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kanban.Dal
{
    public class ProjectProgressDal : BaseDal<ProjectProgress>, IProjectProgressDal
    {
        public ProjectProgressDal()
        {
            TableName = "ProjectProgress";
        }

        public Task<Tuple<IList<object>, int>> GetModelsByPageAsync(string search, int pageSize, int pageIndex)
        {
            string whereSql = "1 = 1";
            if (!string.IsNullOrEmpty(search))
            {
                whereSql += $" AND (Name LIKE '%{search}%' OR ManagerName LIKE '%{search}%' OR SEs LIKE '%{search}%' OR MEs LIKE '%{search}%' OR PRs LIKE '%{search}%' OR EEs LIKE '%{search}%')";
            }
            return GetModelsByPageAsync("*", whereSql, "Id DESC", pageSize, pageIndex);
        }
    }
}
